<?php
class Content_model extends CI_Model
{
	
	function getAllSearch($search_param, $start, $limit){
	
		$this->db->select('SQL_CALC_FOUND_ROWS   c . * , me.menu_name', false);
		$this->db->from('tbl_content c ');
			
		if($search_param){
			$this->db->like('content_name',$search_param);
	
		}
		$this->db->join('tbl_menu me', 'c.menu_id = me.menu_id ', 'left');
		$this->db->order_by("created", "desc");
		$this->db->limit($limit, $start);
	
		$query = $this->db->get();
		$sql= $this->db->last_query();
		
		$this->db->select("FOUND_ROWS() as total_record");
		$rRes = $this->db->get();
		$total_records = $rRes->row_array();
		$total_record = $total_records['total_record'];
		//echo $total_record;
		
		return array(
				'total_record' => $total_record,
				'tbl_content' => $query->result_array(),
				'sql' => $sql,
				
		);
	}
	
	public function getAlltintuc()
	{
		
	}
	
	
	
	
}